<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>新增类型·思通投研·让数据驱动投资价值!</title>

    <link href="${pageContext.request.contextPath }/img/webLogoIcon.png" rel="shortcut icon">
    <link href="${pageContext.request.contextPath }/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/font-awesome.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/custom.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/animate.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/style.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/datatables.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/toastr.min.css" rel="stylesheet"/>
    <link href="${pageContext.request.contextPath }/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/jquery.searchableSelect.css" rel="stylesheet" type="text/css">
    <style>
        .select2_demo_1 {
            float: left;
            width: 120px;
            display: inline;
            margin-left: 10px;
        }

        .form-control {
            display: inline;
        }

        .col-sm-3 {
            float: right;
            width: 560px;
        }

        .input-group {
            float: right;
            width: 240px;
            margin-left: 5px;
        }

        .checkbox {
            padding-left: 35px;
            float: left;
        }
    </style>
</head>

<body>

<div id="wrapper">

    <nav class="navbar-default navbar-static-side" role="navigation">
        <%request.setAttribute("LEFT", "websitelist");%>
        <%@include file="left-factory.jsp" %>
    </nav>

    <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom">
            <jsp:include page="head-factory.jsp" flush="true"/>
        </div>
        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-10">
                <h2>修改种子信息</h2>
            </div>
        </div>
        <div class="wrapper wrapper-content">
            <div class="ibox-content">
                <form action="${pageContext.request.contextPath}/spiderconfig/test" method="post" target="_blank">
                    <span style="font-size: 17px;" id="websiteId" data-id="${websiteId }">网站名称:${websitename } </span>
                    <button class="btn btn-white pull-right"
                            onclick="javascrtpt:window.location.href='${pageContext.request.contextPath }/listtypename?websiteId=${websiteId}'"
                            type="button">返回
                    </button>
                    <div class="table-responsive" style="margin-top: 5%;">
                        <%-- <div class="search-result">
                            <span style="font-size: 17px;">添加一个在【${websitename }】下种子地址配置信息</span>
                            <div style="display: inline;float: right;">
                                            线程数:<select class="form-control" style="display: inline;width: auto;"
                                                id="seedthreadconfig" name="seedthreadconfig">
                                                <option value="1" selected>1条</option>
                                                <option value="5">5条</option>
                                                <option value="10">10条</option>
                                            </select>
                                            &nbsp;&nbsp;&nbsp;&nbsp;抓取间隔:<select class="form-control" style="display: inline;width: auto;"
                                                id="seedintervalconfig" name="seedintervalconfig">
                                                <option value="60000">1分钟</option>
                                                <option value="600000" selected>10分钟</option>
                                                <option value="1800000">30分钟</option>
                                                <option value="3600000">60分钟</option>
                                            </select>
                                            &nbsp;&nbsp;&nbsp;&nbsp;访问URL间隔:<select class="form-control" style="display: inline;width: auto;"
                                                id="seedsleepconfig" name="seedsleepconfig">
                                                <option value="1000">1秒</option>
                                                <option value="2000">2秒</option>
                                                <option value="3000">3秒</option>
                                                <option value="4000">4秒</option>
                                                <option value="5000" selected>5秒</option>
                                            </select>
                                        </div>
                                    </div> --%>
                        <div class="hr-line-dashed"></div>

                        <div class="panel-body">

                            <fieldset class="form-horizontal" style="margin-top: 3%;">

                                <!-- <div class="form-group"><label class="col-sm-2 control-label">选择配置方式:</label>
                                    <div class="col-sm-10"><div class="btn-group">
                            <button id="smartbutton" class="btn btn-white active" type="button" onclick="configTypeChange(1)">智能配置</button>
                            <button id="manualbutton" class="btn btn-white" type="button" onclick="configTypeChange(2)">手动配置</button>
                        </div></div>
                                </div> -->
                                <div class="form-group">
                                    <%--<label class="col-sm-2 control-label"><span style="color:red;font-size:16px;line-height:0px;">*</span>配置站点类型:</label>--%>
                                    <%--<select id="se1" name="seedid" class="form-control" style="display: inline;width: auto;margin-left:15px;">--%>
                                    <%--</select>--%>
                                    <div class="form-group"><label class="col-sm-2 control-label">配置站点类型:</label>
                                        <div class="col-sm-10"><input type="text" id="" name=""
                                                                      class="form-control" style="width: 88%;"
                                                                      value="${response.typename}"
                                                                      disabled="disabled"></div>
                                    </div>
                                    <div class="form-group"><label class="col-sm-2 control-label"><span
                                            style="color:red;font-size:16px;line-height:0px;">*</span>配置接口信息:</label>
                                        <div class="col-sm-10"><input type="text" id="paramexample" name="paramexample"
                                                                      class="form-control" style="width: 88%;"
                                                                      value="${response.paramexample}"></div>
                                    </div>
                                    <div class="form-group"><label class="col-sm-2 control-label">配置参数规则:</label>
                                        <div class="col-sm-10"><input type="text" id="param" name="param"
                                                                      value='${response.param}' class="form-control"
                                                                      style="width: 88%;"></div>
                                    </div>

                                    <div class="form-group" style="display: none" id="testResultDiv"><label
                                            class="col-sm-2 control-label">测试结果数据:</label>
                                        <div class="col-sm-10"><input type="text" id="testResult" name="testResult"
                                                                      value='' class="form-control"
                                                                      style="width: 88%;"></div>
                                    </div>
                                    <%--<div class="form-group"><label class="col-sm-2 control-label"><span style="color:red;font-size:16px;line-height:0px;">*</span>配置错误接口:</label>--%>
                                    <%--<div class="col-sm-10"><input type="text" id="errorparamexample" name="paramexample" class="form-control" style="width: 88%;" value="${response.paramexample}"></div>--%>
                                    <%--</div>--%>
                                    <%--<div class="form-group"><label class="col-sm-2 control-label">配置错误规则:</label>--%>
                                    <%--<div class="col-sm-10"><input type="text" id="errorparam" name="param" value="" class="form-control" style="width: 88%;"></div>--%>
                                    <%--</div>--%>
                                    <!-- <div class="form-group"><label class="col-sm-2 control-label"><span style="color:red;font-size:16px;line-height:0px;">*</span>配置存储规则:</label>
                                    	<div class="checkbox">
                                      <input id="checkbox1" name="seedtextStorageJson" type="checkbox" value="1" class="seedtextStorageJson" checked>
                                      <label for="checkbox1">MySQL</label>
                                 	 </div>
                                 	 <div class="checkbox">
                                  		<input id="checkbox2" name="seedtextStorageJson" type="checkbox" value="2" class="seedtextStorageJson">
                                      	<label for="checkbox2">MongoDB</label>
                                  	</div>
                                  	<input id="spiderId" name="spiderId" type="hidden" value="1">
                                 	 <div class="checkbox">
                                  		<input id="checkbox3" name="seedtextStorageJson" type="checkbox" value="3" class="seedtextStorageJson">
                                     	 <label for="checkbox3">ES</label>
                                 	 </div>
									</div> -->
                                    <!--  <div class="form-group configtype" style="display:none"><label class="col-sm-2 control-label"><span style="color:red;font-size:16px;line-height:0px;">*</span>配置标题规则:</label>
                                         <div class="col-sm-10"><input type="text" id="seedtitleconfig" name="seedtitleconfig" class="form-control" style="width: 88%;" placeholder="请输入标题解析代码"></div>
                                     </div>
                                     <div class="form-group configtype" style="display:none"><label class="col-sm-2 control-label">配置来源规则:</label>
                                         <div class="col-sm-10"><input type="text" id="seedoriginconfig" name="seedoriginconfig" class="form-control" style="width: 88%;" placeholder="请输入来源解析代码"></div>
                                     </div>
                                     <div class="form-group configtype" style="display:none"><label class="col-sm-2 control-label">配置来源URL规则:</label>
                                         <div class="col-sm-10"><input type="text" id="seedoriginurlconfig" name="seedoriginurlconfig" class="form-control" style="width: 88%;" placeholder="请输入来源URL解析代码"></div>
                                     </div>
                                     <div class="form-group configtype" style="display:none"><label class="col-sm-2 control-label"><span style="color:red;font-size:16px;line-height:0px;">*</span>配置日期规则:</label>
                                         <div class="col-sm-10"><input type="text" id="seeddateconfig" name="seeddateconfig" class="form-control" style="width: 88%;" placeholder="请输入日期解析代码"></div>
                                     </div> -->
                                    <div class="form-group configtype" style="display:none"><label
                                            class="col-sm-2 control-label"><span
                                            style="color:red;font-size:16px;line-height:0px;">*</span>正文解析规则:</label>
                                        <div class="col-sm-10"><input type="text" id="seedtextconfig"
                                                                      name="seedtextconfig" class="form-control"
                                                                      style="width: 88%;" placeholder="请输入正文解析规则"></div>
                                    </div>
                            </fieldset>
                            <!-- <button class="btn btn-primary"style="margin-left: 20%;margin-top: 2%;" onclick="check()" type="submit">测试种子</button> -->
                            <button class="btn btn-primary" style="margin-left: 38%;margin-top: 2%;" id="addbutton"
                                    onclick="addwebsitetypename()" type="button">确认修改
                            </button>

                            <button class="btn btn-primary" style="margin-left: 38%;margin-top: 2%;" id="addbutton"
                                    onclick="getInterfaceInfo()" type="button">测试
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <jsp:include page="footer.jsp" flush="true"/>
    </div>
</div>


<!-- Mainly scripts -->
<script src="${pageContext.request.contextPath }/js/jquery-2.1.1.js"></script>
<script src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath }/js/jquery.metisMenu.js"></script>
<script src="${pageContext.request.contextPath }/js/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath }/js/jquery.jeditable.js"></script>
<script src="${pageContext.request.contextPath }/js/datatables.min.js"></script>

<!-- Peity -->
<script src="${pageContext.request.contextPath }/js/jquery.peity.min.js"></script>

<!-- Custom and plugin javascript -->
<script src="${pageContext.request.contextPath }/js/inspinia.js"></script>
<script src="${pageContext.request.contextPath }/js/pace.min.js"></script>

<!-- Peity -->
<script src="${pageContext.request.contextPath }/js/peity-demo.js"></script>

<!-- toastr -->
<script src="${pageContext.request.contextPath }/js/plugins/toastr/toastr.min.js"></script>
<!-- Sweet alert -->
<script src="${pageContext.request.contextPath }/js/plugins/sweetalert/sweetalert.min.js"></script>


<script src="${pageContext.request.contextPath }/js/jquery.searchableSelect.js"></script>
<!-- Page-Level Scripts -->
<script>
    /**
     * 测试
     * */
    function getInterfaceInfo() {
        let data = new Object();
        data.paramexample = $("#paramexample").val();
        data.param = $("#param").val();
        data.transferid = ${transferid};
        data.hbase_table = '${response.hbase_table}';
        data.index = '${response.esindex}';
        data.type = '${response.estype}';
            $.ajax({
                url: "${pageContext.request.contextPath}/website/testSeedInfo",
                type: "post",
                data: JSON.stringify(data),
                contentType: "application/json",
                success: function (res) {
                    // console.log(typeof (res));
                    // console.log(res);
                    $("#testResultDiv").attr("style", "display: block");
                    $("#testResult").val(res);
                },
                error: function (e) {
                    console.error(e);
                }
            });
    }


    /**
     * 修改
     */
    function addwebsitetypename() {
        swal({
                title: "确定修改该此类型?",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: false,
                closeOnCancel: true
            },
            function (isConfirm) {
                if (isConfirm) {
                    let data = new Object();
                    data.paramexample = $("#paramexample").val();
                    data.param = $("#param").val();
                    data.transferid = ${transferid}
                        $.ajax({
                            url: "${pageContext.request.contextPath}/website/editSeedInfo",
                            type: "post",
                            data: JSON.stringify(data),
                            contentType: "application/json",
                            success: function (res) {
                                console.log(typeof (res));
                                console.log(res);
                                let code = JSON.parse(res).code;
                                if (code == '200') {
                                    //toastr.success(res.msg);
                                    swal("添加成功", "该站点类型已被添加", "success");
                                    setTimeout(() => {
                                        window.location.href = "${pageContext.request.contextPath}/listtypename?websiteId=" +${websiteId};
                                    }, 1500);
                                } else {
                                    //toastr.error(res.msg);
                                    swal("添加失败", "该种子修改失败", "error");
                                }
                            },
                            error: function (e) {
                                //toastr.error(res.msg);
                                swal("添加失败", "该种子修改失败", "error");
//                            window.clearInterval(timer);
                            }
                        });
                }
            });
    }
</script>

</body>

</html>
